<include file="../header" />
<body class="J_scroll_fixed">
<style type="text/css">
    .btn,.btn-danger,.btn-info,.btn-success,.btn-warning{
        width: 70px;
        height: 19px;
        line-height: 19px;
        font-size: small;
        padding: 0px 1px 0px 1px;
        margin: 0px 0px 0px 0px;
    }

    select{
        width: auto
    }
</style>
<style>
    *{padding: 0;margin: 0;}
    .main{width: 100%;height: 100%;background-color: rgba(0,0,0,0.6);display: none;position: fixed;z-index: 1;overflow:auto;}
    .mainbox{width: 1024px;height: auto;margin: 0 auto;background-color: #fcfcff;padding: 20px;overflow:auto;}
    .close{color: #ed7667;cursor: pointer;opacity: 1}
</style>
<script>
    $(function(){
        $(".close").click(function(){
            var rowNum= $("#viewTabs tr").size();
            for (var j = 1;  j < rowNum; j++) {
                $("#viewTabs tr").eq(1).remove();
            }
            $("#hospital_order_no").html("");
            $("#hospital_name").html("");
            $("#hospital_operation_name").html("");
            $("#number").html("");
            $("#admin_name").html("");
            $("#create_date").html("");
            $("#op_date").html("");
            $("#doctor_name").html("");
            $("#patient_name").html("");
            $("#undone").html("");
            $("#done").html("");
            $("#note").html("");
            $(".main").fadeOut();
        });
    });
</script>
<script type="text/javascript">
    function showList(hospital_order_id, hospital_order_no, hospital_name, subhospital_name, hospital_operation_name, number, admin_name, create_date, op_date, doctor_name, patient_name, status, note){
        $(".main").fadeIn();

        var data = {};
        data.hospitalOrderId = hospital_order_id;

        $.ajax({
            url: "/admin/HospitalOrder/getHospitalOrderList",
            type: "post",
            data: data,
            dataType: "JSON",
            beforeSend: function () {
                $("#loadingToast").show();
            },
            complete: function () {
                $('#loadingToast').hide();
            },
            success: function (data) {
//                for (var i = 0; i < data.list.length; i++) {
//                    $("select[name=customerId]").append("<option value='" + data.list[i].customer_id + "'>" + data.list[i].nickname + "</option>");
//                }
//获取表格对象
                $("#hospital_order_no").html(hospital_order_no);
                if(subhospital_name != "")
                    $("#hospital_name").html(hospital_name + "：" + subhospital_name);
                else
                    $("#hospital_name").html(hospital_name);

                $("#hospital_operation_name").html("【" + hospital_operation_name + "】");
                $("#number").html(number);
                $("#admin_name").html(admin_name);
                $("#create_date").html(create_date);
                $("#op_date").html(op_date);
                $("#doctor_name").html(doctor_name);
                $("#patient_name").html(patient_name);
                $("#report").attr("href","/admin/hospitalOrder/getTable?id=" + hospital_order_id );
                if(status == '-1'){
                    $("#undone").html("（未出库）");
                    $("#done").html("");
                }
                if(status == '1'){
                    $("#undone").html("");
                    $("#done").html("（已出库）");
                }
                if(note != ""){
                    $("#note").html("备注：" + note);
                }

                var tb1 = $("#viewTabs");                // 找table的ID

//                tb1.html("");
                for (var i = 0; i < data.length; i++) {
                    var $td0 = $("<td style='text-align: center'></td>");
                    $td0.html(i+1);
                    var $td1 = $("<td></td>");
                    $td1.html("<a style='color: #7171cc;'>" + data[i].code + "</a>");
                    var $td2 = $("<td style='text-align: center'></td>");
                    $td2.html("<a style='color: #ed7667;'>" + data[i].number + "</a>");
                    var $td3 = $("<td></td>");
                    $td3.html("<a style='color: #45a1de;'>" + data[i].hospital_product_name + "</a>");


                    var $tr = $("<tr id=\'_tr_"+i+"\' class=\'in-opt\'></tr>");// 创建tr，将3个td放置到tr中
                    $tr.append($td0);
                    $tr.append($td1);
                    $tr.append($td2);
                    $tr.append($td3);

                    //在表格的最后追加新增的tr
                tb1.append($tr);
                }
                return false;
            },
        })
    }

</script>
<php>$imgVersion = "2020101002";</php>
<div class="main">
    <div class="mainbox">
        <div class="close">关闭预览</div>
        <a style="color:#3fcca9;font-weight: bold;" id="hospital_name"></a>
        &nbsp;
        <a style="color:#7171cc;font-weight: bold;" id="hospital_operation_name"></a>
        &nbsp;
        共计 <a style="color:#e97a15;font-weight: bold;" id="number"></a> 件
        &nbsp;
        单号： <a style="color:#45a1de;" id="hospital_order_no"></a>
        &nbsp;
        <a style="color:#30cc80;font-weight: bold;" id="done"> </a><a style="color:#ed7667;font-weight: bold;" id="undone"></a>
        <br/>
        下单日期： <a style="color:#45a1de;" id="create_date"></a>
        &nbsp;
        下单人： <a style="color:#45a1de;" id="admin_name"></a>
        &nbsp;
        手术日期： <a style="color:#45a1de;" id="op_date"></a>
        &nbsp;
        手术医生： <a style="color:#45a1de;" id="doctor_name"></a>
        &nbsp;
        病人姓名： <a style="color:#45a1de;" id="patient_name"></a>
        &nbsp;
        <br/>
        <a class="btn btn-success" id="report" style="float: right;height: 25px; line-height: 25px;">导出表单</a>
        <a style="color:#ed7667;font-weight: bold;" id="note"></a>

        <table class="table table-hover table-bordered" id="viewTabs">
            <thead>
            <tr>
                <th style="min-width: 30px; width: 30px">序号</th>
                <th style="width: 110px">产品编号</th>
                <th style="width: 40px">数量</th>
                <th style="width: auto">产品描述</th>

            </tr>
            </thead>
            <tbody>

            </tbody>
        </table>
    </div>
</div>
<form class="well form-search" method="post" style="float:left;width:100%;margin-bottom: 0px; padding: 5px 10px 5px 10px;" action="{:U('hospitalOrder/index')}">
    <div class="search_type cc mb10">
        <div class="mb10">
        <span class="mr20">
            状态：&nbsp;{:getEnumSelectWidget($statusEnum, "ho#status", $status, 1)}
            &nbsp;
            下单人：
            <select name="ho#employee_id-eq">
                {:getCommonSelectOptionHtml($employee_id, "Admin", "employee_id", "admin_name", null, $user['enterprise_code'], 1)}
            </select>
            <!--
            医院：
            <select name="ho#hospital_id-eq">
                {:getCommonSelectOptionHtml($hospital_id, "Hospital", "hospital_id", "hospital_name", null, $user['enterprise_code'], 1)}
            </select>
            -->
            &nbsp;&nbsp;手术名称：
            <select name="ho#hospital_operation_id-eq">
                {:getCommonSelectOptionHtml($hospital_operation_id, "HospitalOperation", "hospital_operation_id", "hospital_operation_name", null, $user['enterprise_code'], 1)}
            </select>
            &nbsp;订单编号：<input type="text" name="ho#hospital_order_no-like" value="{$hospital_order_no}" style="width: 147px"/>
            <br/>
            医院：
            <select name="h#hospital_id-eq">
                {:getCommonSelectOptionHtml($hospital_id, "Hospital", "hospital_id", "hospital_name", null, $user['enterprise_code'], 1)}
            </select>
            &nbsp;&nbsp;手术医生：<input type="text" name="ho#doctor_name-like" value="{$doctor_name}" style="width: 120px"/>
            &nbsp;&nbsp;病人姓名：<input type="text" name="ho#patient_name-like" value="{$patient_name}" style="width: 120px"/>
            &nbsp;&nbsp;&nbsp;&nbsp;下单开始日期：<input type="text" value="{$begin_time}" style="width: 100px" class="date J_date" name="ho#create_date-egt" />
            &nbsp;&nbsp;下单截止日期：<input type="text" value="{$end_time}" style="width: 100px" class="date J_date" name="ho#create_date-elt" />
            <br/>

            每页显示：
            <select name="pageSize" style="color: #1dccaa">
                <option value=''></option>
                <php>$selected=($pageSize == 20)?"selected":"";</php>
                <option value='20' {$selected}>20 条</option>
                <php>$selected=($pageSize == 50)?"selected":"";</php>
                <option value='50' {$selected}>50 条</option>
                <php>$selected=($pageSize == 100)?"selected":"";</php>
                <option value='100' {$selected}>100 条</option>
                <php>$selected=($pageSize == -1)?"selected":"";</php>
                <option value='-1' {$selected}>全部</option>
            </select>

            &nbsp;&nbsp;&nbsp;
            <button class="btn btn-primary" type="submit">搜索</button>
            <a class="btn" href="{:U('hospitalOrder/index')}">重置</a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a style="font-weight: bold;color: #1dccaa">
                【查询结果】
            </a>
            <a style="color: #1dccaa">
                条数：{$totalCount}
            </a>
        </span>
        </div>
    </div>
</form>

<div class="wrap J_check_wrap" style="padding: 2px 5px 0px 5px; overflow-x:auto;">
    <ul class="nav nav-tabs">
        <li class="active"><a>相关信息</a></li>
        <!--<li><a name="downloadExcel" style="cursor: pointer;">导出选中报表</a></li>-->
    </ul>
    <table class="table table-hover table-bordered">
        <thead>
        <tr>
            <!--<th style="min-width: 10px; width: 10px"><input type="checkbox" name="checkAll"></th>-->
            <th style="min-width: 150px" width="150px">订单信息</th>
            <th style="min-width: 550px" width="550px">手术信息</th>
            <th style="min-width: 60px" width="60px">订单详情</th>
            <th width="auto">备注</th>
            <th style="min-width: 130px" width="130px">状态</th>
            <th style="min-width: 65px" width="65px">操作</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="orderList" item="vo">
            <tr>
                <!--php>
                    $checkName = $vo["hospital_order_id"];
                </php>
                <td><input type="checkbox" class="checkItem" name="{$checkName}"></td-->
                <td>({$vo.hospital_order_id})&nbsp;<a style="font-weight: bold; color:#7171cc">{$vo.hospital_order_no}</a><br>
                    <if condition="$vo['status'] eq $statusEnum['END_DELIVERY']">
                        出库人：<a style="font-weight: bold;color: #45a1de">{$vo.delivery_name}</a><br>{$vo.outstock_time}
                        <br>{$vo.express_company}  {$vo.delivery_number}
                        <else/>
                        更新时间：<br>{$vo.update_time}
                    </if>

                </td>
                <td><a style="font-weight: bold">{$vo.hospital_name}</a>
                    <if condition="$vo['subhospital_name'] neq ''">
                        <a style="font-weight: bold; ">( {$vo.subhospital_name} )</a>
                    </if>
                    &nbsp;
                    <a style="font-weight: bold; color:#7171cc">【{$vo.hospital_operation_name}】</a> &nbsp;数量：<a style="color: #ed7667;font-weight: bold">{$vo.number}</a> 件
                    <br>
                    下单日期：<a style="font-weight: bold;color: #45A1DE">{$vo.create_date}</a> &nbsp;下单人：<a style="font-weight: bold;color: #45a1de">{$vo.admin_name}</a><br>手术日期：<a style="font-weight: bold; color:#3fcca9">{$vo.op_date}</a> &nbsp;&nbsp;医生：<a style="font-weight: bold; color:#3fcca9">{$vo.doctor_name}</a>&nbsp;&nbsp;患者：<a style="color: #7171CC">{$vo.patient_name}</a>
                </td>

                <!--td>
                    <php>
                        $reportArr = explode(',', $vo["report_list"]);
                        foreach ($reportArr as $key=>$report){
                            if($key % 2 == 1){
                    </php>
                                <a>{$report}</a>&nbsp;&nbsp;&nbsp;
                    <php>
                            }else{
                    </php>
                                <a style="color: #7171CC">{$report}</a>&nbsp;&nbsp;&nbsp;
                    <php>
                            }
                        }
                    </php>
                </td-->
                <!--<td><a style="color: #45A1DE">{$vo.report_list}</a></td>-->
                <td style="vertical-align: middle;text-align: center"><a style="color: #45A1DE; cursor:pointer;font-weight: bold; text-decoration:none; border-bottom: 1px solid; " onclick='javascript:showList("{$vo.hospital_order_id}", "{$vo.hospital_order_no}", "{$vo.hospital_name}", "{$vo.subhospital_name}", "{$vo.hospital_operation_name}", "{$vo.number}", "{$vo.admin_name}", "{$vo.create_date}", "{$vo.op_date}", "{$vo.doctor_name}", "{$vo.patient_name}", "{$vo.status}", "{$vo.note}" )'>点击预览</a></td>
                <td><a style="color: #ed7667; font-weight: bold">{$vo.note}</a></td>
                <td>
                    <php>
                        $statusArr = array();
                        $statusArr["-1"] = "处理中";
                        $statusArr["1"] = "已出库";
                        $statusArr[$vo["status"]] .= "亮";
                    </php>
                    <div style="padding: 0px 2px 0px 2px;">
                        <img style="height: 58px" src="/Template/images/{$statusArr.-1}.png?v={$imgVersion}"/>
                        <img style="height: 58px" src="/Template/images/arrow.png"/>
                        <img style="height: 58px" src="/Template/images/{$statusArr.1}.png?v={$imgVersion}"/>
                    </div>
                </td>
                <td>
                    <a class="btn btn-success" href='{:U("hospitalOrder/getTable",array("id"=>$vo["hospital_order_id"]))}'>导出表单</a>
                    <br>
                    <php>
                        $outstoreStatus = -1;
                        $role = explode(',',$user["role"]);
                        if(in_role($role,"1,13") && $vo["status"] == -1){
                        $outstoreStatus = 1;
                        }
                    </php>

                    <if condition="$vo['status'] eq $statusEnum['WAITING_PROCESS'] && $outstoreStatus eq '1'">
                        <a class="btn btn-info"  href='{:U("hospitalOrder/outStock",array("id"=>$vo["hospital_order_id"]))}'>复核出库</a>
                        <a class="btn btn-danger" href='{:U("hospitalOrder/outStock",array("id"=>$vo["hospital_order_id"], "closed"=>"yes"))}' >关闭订单</a>
                    </if>
                </td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page}</div>
</div>

<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>